
#ifndef CAMARA_REF_LOOKAT_H_
#define CAMARA_REF_LOOKAT_H_

#include "camara.h"

class CamLookAt : public Camara {
   private:
      float &x;
      float &y;
      float &z;

      float &dx;
      float &dy;
      float &dz;

      float &ux;
      float &uy;
      float &uz;

      float eyeFactor[3];
      float pointFactor[3];
      float upFactor[3];

   public:

      CamLookAt(float &x, float &y, float &z,
            float &dx, float &dy, float &dz,
            float &ux, float &uy, float &uz)
         : x(x), y(y), z(z),
         dx(dx), dy(dy), dz(dz),
         ux(ux), uy(uy), uz(uz) {

            for(int i=0; i < 3; ++i) 
               eyeFactor[i] = pointFactor[i] = upFactor[i] = 0.0;
         }

      /*
       * Se posiciona la camara en:
       *    
       *  x + efx * dx; y + efy * dy ; z + efz
       *
       * Y se apunta a:
       *
       *  x + pfx * dx; y + pfy * dy ; z + pfz
       *
       * Siendo su direccion "up"
       *
       *  ufx * ux ; ufy * uy ; ufz * uz
       *
       *  */
      void configEyeFactor(float efx, float efy, float efz) {
         eyeFactor[0] = efx;
         eyeFactor[1] = efy;
         eyeFactor[2] = efz;
      }
      void configPointFactor(float pfx, float pfy, float pfz) {
         pointFactor[0] = pfx;
         pointFactor[1] = pfy;
         pointFactor[2] = pfz;
      }
      void configUpFactor(float ufx, float ufy, float ufz) {
         upFactor[0] = ufx;
         upFactor[1] = ufy;
         upFactor[2] = ufz;
      }

      virtual void ver() const {
         gluLookAt(x + eyeFactor[0]*dx, y + eyeFactor[1]*dy, z + eyeFactor[2], 
               x + pointFactor[0]*dx, y + pointFactor[1]*dy, z + pointFactor[2],
               upFactor[0] * ux, upFactor[1] * uy, upFactor[2] * uz
               );
      }
};

#endif
